package com.zhsj.OkeHomeConsumption.ui.fragment.minehome;

import android.os.Bundle;
import android.widget.TextView;

import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.common.MyActivity;
import com.zhsj.OkeHomeConsumption.common.MyApplication;
import com.zhsj.OkeHomeConsumption.empty.VersionInfo;
import com.zhsj.OkeHomeConsumption.utils.DownloadAppUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 版本更新页面
 */
public class VersionUpdataActivity extends MyActivity {
    @BindView(R.id.versionname_text)
    TextView versionnameText;
    @BindView(R.id.content_text)
    TextView contentText;
    @BindView(R.id.updata_text)
    TextView updataText;

    VersionInfo versionInfo;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_versionupdata;
    }

    @Override
    protected int getTitleId() {
        return R.id.title_back;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        versionInfo = (VersionInfo) getIntent().getExtras().getSerializable("versioninfo");
        versionnameText.setText(versionInfo.getClientVersion());
        contentText.setText(versionInfo.getReleaseNotes());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.updata_text)
    public void onViewClicked() {
        DownloadAppUtils.downloadForAutoInstall(MyApplication.getContext(),
                versionInfo.getUrl(), "oke_home_consum.apk", "更新聚联惠");
    }
}
